#pragma once
#include "DXUT.h"
#include "DXUTcamera.h"
#include "..\\Utility\\DirectoryUtil.h"
#include "..\\Utility\\UtilityFunctions.h"
#include "..\\Effects11\\Inc\\d3dx11effect.h"
#include "Vertex.h"
enum RENDERMESHTECH
{
	RENDERSTATICMESH,
	RENDERSKINMESH,
	RENDERMORPHMESH,
	RENDERMIXEDMESHES,
};
class CMeshRender
{
public:
	CMeshRender(void);
	virtual ~CMeshRender(void);
	//create VB and IB for 3D triangulate models
	virtual HRESULT OnD3D11CreateDevice( ID3D11Device* pd3dDevice, ID3DX11EffectTechnique* pTech, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, 
		CDirectoryUtil* pDirUtil, void* pUserContext );
	virtual HRESULT OnD3D11ResizedSwapChain( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain,
		const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, CDirectoryUtil* pDirUtil, void* pUserContext );
	virtual void OnD3D11ReleasingSwapChain( void* pUserContext );
	virtual void OnD3D11DestroyDevice( void* pUserContext );	

	virtual void Render( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, ID3DX11Effect* pEffect, ID3DX11EffectTechnique* pRenderTech, 
		enum RENDERMESHTECH iMeshType, const D3DXMATRIX& mWorldCamera, double fTime, float fElapsedTime, void* pUserContext );
	virtual bool LoadModel(const char* pFileName,ID3D11Device* pd3dDevice);
	inline unsigned int GetStrideSize(){return STRIDE_SIZE;}	
    inline ID3D11Buffer* GetVB(){return m_pVB;}
    inline ID3D11Buffer* GetIB(){return m_pIB;}
	inline bool isModelReady(){return m_bModelReady;}
	inline D3DXMATRIX& GetWorldMatrix(){return m_mWorldModel;}
	inline void SetWorldMatrix(D3DXMATRIX& mat){m_mWorldModel = mat;}
    inline enum VERTEXTYPE GetVertType(){return m_iVType;}
    inline 	void NeedLocalCoords(bool bNeed)
	{
		m_bConstructLocalCoords = bNeed;
	}
    inline bool bLocalCoordsSupport() {return m_bSupportLocalCoords;}
protected:
	//D3D series members
	ID3D11Buffer*				m_pVB;
	ID3D11Buffer*               m_pIB;
	ID3D11InputLayout*          m_pVertexLayout;
	//vertex type;
	enum VERTEXTYPE				m_iVType;
    unsigned int				STRIDE_SIZE;
	bool                        m_bModelReady;
	bool						m_b32bitIndex;
	D3DXMATRIX                  m_mWorldModel;
	D3DXVECTOR3                 m_vCenter;
	float						m_fRadius;
	bool                        m_bSupportLocalCoords;
	bool						m_bConstructLocalCoords;
};

